﻿var HugryHero = cc.Sprite.extend({
    fast: false,
    animation: null,
    ctor: function() {
        this._super("#fly_0001.png");
        this.animation = new cc.Animation();
        for (var i = 1; i < 20; ++i) {
            this.animation.addSpriteFrame(cc.spriteFrameCache.getSpriteFrame("fly_00" + (i < 10?('0'+i):i)+".png"));
        }
        this.animation.setDelayPerUnit(1 / 20);
        var action = cc.animate(this.animation).repeatForever();
        this.runAction(action);
    },
    toggleSpeed:function(fast) {
        if (fast == this.fast)
            return;
        this.fast = fast;
        this.stopAllAction();
        if (!fast) {
            this.animation.setDelayPerUnit(1 / 20);
        } else {
            this.animation.setDelayPerUnit(1 / 60);
        }
        var action = cc.animate(this.animation).repeatForever();
        this.runAction(action);

    }

});